package org.wzl.databasesync.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wzl.databasesync.dto.DatabaseInfo;
import org.wzl.databasesync.service.SqlGenService;
import org.wzl.databasesync.utils.Resp;

@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    private SqlGenService sqlGenService;

    @PostMapping("/getAllTables")
    public Resp<?> getAllTables(@RequestBody DatabaseInfo databaseInfo) throws Exception {
        return Resp.ok(sqlGenService.getAllTables(databaseInfo));
    }

    @PostMapping("/getTableDesc")
    public Resp<?> getTableDesc(@RequestBody DatabaseInfo databaseInfo,
                                String tableName) {
        return Resp.ok(sqlGenService.getTableDesc(databaseInfo, tableName));
    }

}
